﻿using System;
using Windows.ApplicationModel;
using XiaoweiUWP.Services;

namespace XiaoweiUWP.Settings
{
    public enum LaunchType
    {
        Normal, //点击图标启动
        Auto,   //开机启动
        Voice,  //唤醒启动
    }

    public enum WakeupType
    {
        Voice,
        PushToTalk,
        Hotkey
    }
    public static class AppState
    {
        public static bool IsLaunched { get; set; } = false;

        public static bool IsFetchingLicenseAndInitializing { get; set; } = false;

        public static event Action IsLaunchCompletedChanged;
        private static bool isLaunchCompleted  = false;
        public static bool IsLaunchCompleted { 
            get 
            {
                return isLaunchCompleted;
            }
            set 
            {
                if (isLaunchCompleted != value)
                {
                    isLaunchCompleted = value;
                    IsLaunchCompletedChanged?.Invoke();
                }
            } 
        }
        public static LaunchType LaunchType { get; set; } = LaunchType.Normal;
        public static Int64 LaunchedAt { get; set; } = 0;

        public static event Action IsLoginChanged;
        private static bool isLogin = false;
        public static bool IsLogin {
            get
            {
                return isLogin;
            }
            set
            {
                if(isLogin!=value)
                {
                    isLogin = value;
                    IsLoginChanged?.Invoke();
                }
            }
        }

        public static bool IsClosing { get; set; } = false;

        public static bool IsLaunchingForeground { get; set; } = false;

        public static bool IsNavigated { get; set; } = false;

        public static bool IsFetchingToken { get; set; } = false;
        public static bool IsForceUpdate { get; set; } = false;
        public static int AsrPid { get; set; } = 0;
        public static bool wakeFromSleep { get; set; } = false;

        public static bool skipWakingup { get; set; } = false;
        //public static bool isPlayingResonpse = false;
        //public static bool isNotAllowed = false;
        public static Version Version
        {
            get
            {
                PackageVersion v = Package.Current.Id.Version;
                return Version.Parse($"{ v.Major}.{ v.Minor}.{ v.Build}.{ v.Revision}");
                //return Version.Parse($"2.1.58.0");
            }
        }

        public static bool IsLockscreenUI { get; set; } = false;
    }
}
